﻿@using Opserver.Views.Hub
@inject Opserver.Data.Dashboard.DashboardModule Dashboard
@inject Opserver.Data.SQL.SQLModule Sql
@inject Opserver.Data.Elastic.ElasticModule Elastic
@inject Opserver.Data.HAProxy.HAProxyModule HAProxy
@model HubModel
@{
    this.SetPageTitle("Hub");

    // Just making this compile and run for now
    // TODO: Move to registration elsewhere, or maybe we look for Hub.cshtml (or something) in those view folders
    // Ideally, the data layer doesn't know about view names
    var views = new List<string>();
    if (Dashboard.Enabled)
    {
        views.Add("Index.Dashboard");
    }
    if (Sql.Enabled)
    {
        views.Add("Index.SQL");
    }
    if (Elastic.Enabled)
    {
        views.Add("Index.Elastic");
    }
    if (HAProxy.Enabled)
    {
        views.Add("Index.HAProxy");
    }
}
@section head {
    <script>
        $(function() {
            Status.Dashboard.init({ refresh: 60 });
        });
    </script>
}
<div>
    <div class="small js-refresh" data-name="all-servers">
        <div class="col-md-4">
            @for (var i = 0; i < views.Count; i += 2)
            {
                <partial name="@views[i]" />
            }
        </div>
        <div class="col-md-4">
            @for (var i = 1; i < views.Count; i += 2)
            {
                <partial name="@views[i]" />
            }
        </div>
        <div class="col-md-4">
            <partial name="Index.Issues" />
        </div>
    </div>
</div>